//package com.jzo2o.foundations.handler;
//
///**
// * @author Mr.M
// * @version 1.0
// * @description TODO
// * @date 2024/10/3 7:38
// */
//
//import com.jzo2o.foundations.constants.IndexConstants;
//import com.jzo2o.foundations.model.domain.ServeSync;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * 服务信息同步程序
// *
// * @author itcast
// * @create 2023/8/15 18:14
// **/
//@Component
//public class ServeCanalDataSyncHandler extends AbstractCanalRabbitMqMsgListener<ServeSync> {
//
//    @Resource
//    private ElasticSearchTemplate elasticSearchTemplate;
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(name = "canal-mq-jzo2o-foundations"),
//            exchange = @Exchange(name = "exchange.canal-jzo2o", type = ExchangeTypes.TOPIC),
//            key = "canal-mq-jzo2o-foundations"),
//            concurrency = "1"
//    )
//    public void onMessage(Message message) throws Exception {
//        parseMsg(message);
//    }
//
//    @Override
//    public void batchSave(List<ServeSync> data) {
//        Boolean aBoolean = elasticSearchTemplate.opsForDoc().batchInsert(IndexConstants.SERVE, data);
//        if (!aBoolean) {
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//            throw new RuntimeException("同步失败");
//        }
//    }
//
//    @Override
//    public void batchDelete(List<Long> ids) {
//        Boolean aBoolean = elasticSearchTemplate.opsForDoc().batchDelete(IndexConstants.SERVE, ids);
//        if (!aBoolean) {
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//            throw new RuntimeException("同步失败");
//        }
//    }
//}
